<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>用户信息</title>
<t:base type="jquery,easyui,tools"></t:base>
 <%--update-start--Author:jg_renjie  Date:20160320 for：#942 【组件封装】组织机构弹出模式，目前是列表，得改造成树方式--%>
    <%--update-start--Author:zhangguoming  Date:20140825 for：添加组织机构combobox多选的处理方法--%>
    <script>
        var idCardNoUtil = (function(){
            /*省,直辖市代码表*/
            var provinceAndCitys = {11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",
                31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",
                45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",
                65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"};
            /*每位加权因子*/
            var powers = ["7","9","10","5","8","4","2","1","6","3","7","9","10","5","8","4","2"];
            /*第18位校检码*/
            var parityBit = ["1","0","X","9","8","7","6","5","4","3","2"];
            /*性别*/
            var genders = {male:"男",female:"女"};
            /*校验地址码*/
            var checkAddressCode = function(addressCode){
                var check = /^[1-9]\d{5}$/.test(addressCode);
                if(!check) return false;
                if(provinceAndCitys[parseInt(addressCode.substring(0,2))]){
                    return true;
                }else{
                    return false;
                }
            };
            /*校验日期码*/
            var checkBirthDayCode=function(birDayCode){
                var check = /^[1-9]\d{3}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))$/.test(birDayCode);
                if(!check) return false;
                var yyyy = parseInt(birDayCode.substring(0,4),10);
                var mm = parseInt(birDayCode.substring(4,6),10);
                var dd = parseInt(birDayCode.substring(6),10);
                var xdata = new Date(yyyy,mm-1,dd);
                if(xdata > new Date()){
                    return false;//生日不能大于当前日期
                }else if ( ( xdata.getFullYear() == yyyy ) && ( xdata.getMonth () == mm - 1 ) && ( xdata.getDate() == dd ) ){
                    return true;
                }else{
                    return false;
                }
            };
            /*计算校检码*/
            var getParityBit = function(idCardNo){
                var id17 = idCardNo.substring(0,17);
                /*加权 */
                var power = 0;
                for(var i=0;i<17;i++){
                    power += parseInt(id17.charAt(i),10) * parseInt(powers[i]);
                }
                /*取模*/
                var mod = power % 11;
                return parityBit[mod];
            };

            /*验证校检码*/
            var checkParityBit = function(idCardNo){
                var parityBit = idCardNo.charAt(17).toUpperCase();
                if(getParityBit(idCardNo) == parityBit){
                    return true;
                }else{
                    return false;
                }
            };

            /*校验15位或18位的身份证号码*/
            var checkIdCardNo = function(idCardNo){
                //15位和18位身份证号码的基本校验
                var check = /^\d{15}|(\d{17}(\d|x|X))$/.test(idCardNo);
                if(!check) return false;
                //判断长度为15位或18位
                if(idCardNo.length==15){
                    return check15IdCardNo(idCardNo);
                }else if(idCardNo.length==18){
                    return check18IdCardNo(idCardNo);
                }else{
                    return false;
                }
            };

            //校验15位的身份证号码
            var check15IdCardNo = function(idCardNo){
                //15位身份证号码的基本校验
                var check = /^[1-9]\d{7}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}$/.test(idCardNo);
                if(!check) return false;
                //校验地址码
                var addressCode = idCardNo.substring(0,6);
                check = checkAddressCode(addressCode);
                if(!check) return false;
                var birDayCode = '19' + idCardNo.substring(6,12);
                //校验日期码
                return checkBirthDayCode(birDayCode);
            };

            //校验18位的身份证号码
            var check18IdCardNo = function(idCardNo){
                //18位身份证号码的基本格式校验
                var check = /^[1-9]\d{5}[1-9]\d{3}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}(\d|x|X)$/.test(idCardNo);
                if(!check) return false;
                //校验地址码
                var addressCode = idCardNo.substring(0,6);
                check = checkAddressCode(addressCode);
                if(!check) return false;
                //校验日期码
                var birDayCode = idCardNo.substring(6,14);
                check = checkBirthDayCode(birDayCode);
                if(!check) return false;
                //验证校检码
                return checkParityBit(idCardNo);
            };
            return {
                checkIdCard:checkIdCardNo
            };
        })();
<%-- //        update-start--Author:zhangguoming  Date:20140826 for：将combobox修改为combotree
        function setOrgIds() {
//            var orgIds = $("#orgSelect").combobox("getValues");
            var orgIds = $("#orgSelect").combotree("getValues");
            $("#orgIds").val(orgIds);
        }
        $(function() {
            $("#orgSelect").combotree({
                onChange: function(n, o) {
                    if($("#orgSelect").combotree("getValues") != "") {
                        $("#orgSelect option").eq(1).attr("selected", true);
                    } else {
                        $("#orgSelect option").eq(1).attr("selected", false);
                    }
                }
            });
            $("#orgSelect").combobox("setValues", ${orgIdList});
            $("#orgSelect").combotree("setValues", ${orgIdList});
        }); --%>


		function openDepartmentSelect() {
			$.dialog.setting.zIndex = 9999; 
			
			var orgIds = $("#orgIds").val();
			
			$.dialog({content: 'url:departController.do?departSelect&orgIds='+orgIds, zIndex: 2300, title: '组织机构列表', lock: true, width: '400px', height: '350px', opacity: 0.4, button: [
			   {name: '<t:mutiLang langKey="common.confirm"/>', callback: callbackDepartmentSelect, focus: true},
			   {name: '<t:mutiLang langKey="common.cancel"/>', callback: function (){}}
		   ]}).zindex();
		}
			
		function callbackDepartmentSelect() {
            var iframe = this.iframe.contentWindow;
            var treeObj = iframe.$.fn.zTree.getZTreeObj("departSelect");
            var nodes = treeObj.getCheckedNodes(true);
            if(nodes.length>0){
                var ids='',names='';
			    for(i=0;i<nodes.length;i++){
			        var node = nodes[i];
			        ids += node.id;
                    names += node.name;
                    if(i != (nodes.length-1)){
                        ids += ',';
                        names += ',';
                    }
			    }
                $('#departname').val(names);
			    $('#departname').blur();
			    $('#orgIds').val(ids);
			}
		}
		
		function callbackClean(){
			$('#departname').val('');
			 $('#orgIds').val('');	
		}
		function validId(e){
            if(!idCardNoUtil.checkIdCard($(e).val())){
                $(e).parent().children(".Validform_checktip").addClass("Validform_wrong");
                $(e).parent().children(".Validform_checktip").html("身份证号码无效");
                $(e).val("");
            }
        }
		function setOrgIds() {}
		$(function(){
			$("#departname").prev().hide();
		});
 <%--update-end--Author:zhangguoming  Date:20140825 for：添加组织机构combobox多选的处理方法--%>
    </script>
    <style type="text/css">
        #file_upload1{
            display: inline-block;
        }
        #file_upload1span .uploadify{
            margin-bottom: 0em;
        }
    </style>
    <%--update-end--Author:jg_renjie  Date:20160320 for：#942 【组件封装】组织机构弹出模式，目前是列表，得改造成树方式--%>
    <link rel="stylesheet" href="plug-in/uploadify/css/uploadify.css" type="text/css">
    <script type="text/javascript" src="plug-in/uploadify/jquery.uploadify-3.1.js"></script>
    <script type="text/javascript" src="plug-in/tools/Map.js"></script>
</head>
<body style="overflow-y: hidden" scroll="no">
<%--update-start--Author:zhangguoming  Date:20140825 for：格式化页面代码 并 添加组织机构combobox多选框--%>
<t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" action="userController.do?saveUser" beforeSubmit="setOrgIds">
	<input id="id" name="id" type="hidden" value="${user.id }">
	<table style="width: 600px;" cellpadding="0" cellspacing="1" class="formtable">
		<tr>
			<td align="right" width="25%" nowrap>
                <label class="Validform_label">  <t:mutiLang langKey="common.username"/>:  </label>
            </td>
			<td class="value" width="85%">
                <c:if test="${user.id!=null }"> ${user.userName } </c:if>
                <c:if test="${user.id==null }">
                    <input id="userName" class="inputxt" name="userName" validType="t_s_base_user,userName,id" value="${user.userName }" datatype="s2-10" />
                    <span class="Validform_checktip"> <t:mutiLang langKey="username.rang2to10"/></span>
                </c:if>
            </td>
		</tr>
		<tr>
			<td align="right" width="10%" nowrap><label class="Validform_label"> <t:mutiLang langKey="common.real.name"/>: </label></td>
			<td class="value" width="10%">
                <input id="realName" class="inputxt" name="realName" value="${user.realName }" datatype="s2-10">
                <span class="Validform_checktip"><t:mutiLang langKey="fill.realname"/></span>
            </td>
		</tr>
		<c:if test="${user.id==null }">
			<tr>
				<td align="right"><label class="Validform_label"> <t:mutiLang langKey="common.password"/>: </label></td>
				<td class="value">
                    <input type="password" class="inputxt" value="" name="password" plugin="passwordStrength" datatype="*6-18" errormsg="" />
                    <span class="passwordStrength" style="display: none;">
                        <span><t:mutiLang langKey="common.weak"/></span>
                        <span><t:mutiLang langKey="common.middle"/></span>
                        <span class="last"><t:mutiLang langKey="common.strong"/></span>
                    </span>
                    <span class="Validform_checktip"> <t:mutiLang langKey="password.rang6to18"/></span>
                </td>
			</tr>
			<tr>
				<td align="right"><label class="Validform_label"> <t:mutiLang langKey="common.repeat.password"/>: </label></td>
				<td class="value">
                    <input id="repassword" class="inputxt" type="password" value="${user.password}" recheck="password" datatype="*6-18" errormsg="两次输入的密码不一致！">
                    <span class="Validform_checktip"><t:mutiLang langKey="common.repeat.password"/></span>
                </td>
			</tr>
		</c:if>
		<tr>
			<td align="right"><label class="Validform_label"> <t:mutiLang langKey="common.department"/>: </label></td>
			<td class="value">
				 <%--update-start--Author:jg_renjie  Date:20160320 for：#942 【组件封装】组织机构弹出模式，目前是列表，得改造成树方式--%>
                <%--update-start--Author:zhangguoming  Date:20140826 for：将combobox修改为combotree--%>
                <%--<select class="easyui-combobox" data-options="multiple:true, editable: false" id="orgSelect" datatype="*">--%>
                <%--<select class="easyui-combotree" data-options="url:'departController.do?getOrgTree', multiple:true, cascadeCheck:false"
                        id="orgSelect" name="orgSelect" datatype="select1">
                update-end--Author:zhangguoming  Date:20140826 for：将combobox修改为combotree
                    <c:forEach items="${departList}" var="depart">
                        <option value="${depart.id }">${depart.departname}</option>
                    </c:forEach>
                </select> --%>
                <%--  <t:departSelect departId="${tsDepart.id }" departName="${tsDepart.departname }"></t:departSelect>--%>
                
                <input id="departname" name="departname" type="text" readonly="readonly" class="inputxt" datatype="*" value="${departname}">
                <input id="orgIds" name="orgIds" type="hidden" value="${orgIds}">
                <a href="#" class="easyui-linkbutton" plain="true" icon="icon-search" id="departSearch" onclick="openDepartmentSelect()">选择</a>
                <a href="#" class="easyui-linkbutton" plain="true" icon="icon-redo" id="departRedo" onclick="callbackClean()">清空</a>
                 <%--update-end--Author:jg_renjie  Date:20160320 for：#942 【组件封装】组织机构弹出模式，目前是列表，得改造成树方式--%>
                <span class="Validform_checktip"><t:mutiLang langKey="please.muti.department"/></span>
            </td>
		</tr>
		<tr>
			<td align="right"><label class="Validform_label"> <t:mutiLang langKey="common.role"/>: </label></td>
			<td class="value" nowrap>
                <input name="roleid" name="roleid" type="hidden" value="${id}" id="roleid">
                <input name="roleName" class="inputxt" value="${roleName }" id="roleName" readonly="readonly" datatype="*" />
                <t:choose hiddenName="roleid" hiddenid="id" url="userController.do?roles" name="roleList"
                          icon="icon-search" title="common.role.list" textname="roleName" isclear="true" isInit="true"></t:choose>
                <span class="Validform_checktip"><t:mutiLang langKey="role.muti.select"/></span>
            </td>
		</tr>
		<tr>
			<td align="right" nowrap><label class="Validform_label">  <t:mutiLang langKey="common.phone"/>: </label></td>
			<td class="value">
                <input class="inputxt" name="mobilePhone" value="${user.mobilePhone}" datatype="m" errormsg="手机号码不正确" ignore="ignore">
                <span class="Validform_checktip"></span>
            </td>
		</tr>
        <tr>
            <td align="right" nowrap><label class="Validform_label">身份证: </label></td>
            <td class="value">
                <input class="inputxt" name="cardedNumber" value="${user.cardedNumber}" datatype="/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/" onchange="validId(this)" errormsg="请输入身份证号">
                <input type="hidden" name = "cardedSrc" value="${user.cardedSrc}" datatype="/upload/" nullmsg="请上传照片" errormsg="请上传照片2">
                <span id="file_upload1span">
                    <div id="file_upload1" class="uploadify" style="height:25px;width:76px;"></div>
                </span>
                <span class="Validform_checktip"></span>
            </td>
        </tr>
		<tr>
			<td align="right"><label class="Validform_label"> <t:mutiLang langKey="common.tel"/>: </label></td>
			<td class="value">
                <input class="inputxt" name="officePhone" value="${user.officePhone}" datatype="n" errormsg="办公室电话不正确" ignore="ignore">
                <span class="Validform_checktip"></span>
            </td>
		</tr>
		<tr>
			<td align="right"><label class="Validform_label"> <t:mutiLang langKey="common.common.mail"/>: </label></td>
			<td class="value">
                <input class="inputxt" name="email" value="${user.email}" datatype="e" errormsg="邮箱格式不正确!" ignore="ignore">
                <span class="Validform_checktip"></span>
            </td>
		</tr
        <c:if test="${user != null }">
        <tr>
            <td align="right"><label class="Validform_label">推荐码: </label></td>
            <td class="value">
                ${reccodeEntity.recCode}
            </td>
        </tr>
        </c:if>
	</table>
</t:formvalid>
<script type="text/javascript">
    $(function() {
        $('#file_upload1').uploadify({
            buttonText: '选择',
            auto: true,
            progressData: 'speed',
            multi: false,
            height: 25,
            width: 76,
            overrideEvents: ['onDialogClose'],
            fileTypeDesc: '文件格式:',
            queueID: 'filediv',
            fileTypeExts: '*.jpg;*,jpeg;*.png;*.gif;*.bmp;*.ico;*.tif',
            fileSizeLimit: '5MB',
            swf: 'plug-in/uploadify/uploadify.swf',
            uploader: 'departController.do?upload',
            onUploadStart: function (file) {
            },
            onQueueComplete: function (queueData) {

            },
            onUploadSuccess: function (file, data, response) {
                var d = $.parseJSON(data);
                if (d.status == "1") {
                    $("#file_upload1-button span").html("已上传");
                    $("input[name='cardedSrc']").val(d.urls[0]);
                }else{
                    $("#file_upload1-button span").html("上传失败");
                }
                var win = frameElement.api.opener;
                win.tip(d.message);
            },
            onFallback: function () {
                tip("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试")
            },
            onSelectError: function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        tip("上传的文件数量已经超出系统限制的" + $('#file_upload1').uploadify('settings', 'queueSizeLimit') + "个文件！");
                        break;
                    case -110:
                        tip("文件 [" + file.name + "] 大小超出系统限制的" + $('#file_upload1').uploadify('settings', 'fileSizeLimit') + "大小！");
                        break;
                    case -120:
                        tip("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        tip("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            },
            onUploadProgress: function (file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {
            }
        });
    });
</script>
<%--update-end--Author:zhangguoming  Date:20140825 for：格式化页面代码 并 添加组织机构combobox多选框--%>
</body>